<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>志愿者管理系统</title>
    <script>
        // 页面加载时设置默认用户信息
        (function() {
            // 设置默认的志愿者管理用户信息
            if (!localStorage.getItem('volunteerCurrentUser')) {
                localStorage.setItem('volunteerCurrentUser', JSON.stringify({
                    name: '志愿者管理员',
                    role: '志愿者管理员'
                }));
                localStorage.setItem('volunteerIsLoggedIn', 'true');
            }
        })();
    </script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #333;
            min-height: 100vh;
        }

        .container {
            display: flex;
            min-height: 100vh;
        }

        /* 左侧侧边栏 */
        .sidebar {
            width: 280px;
            background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 50%, #3b82f6 100%);
            color: white;
            padding: 0;
            box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
            position: fixed;
            height: 100vh;
            overflow-y: auto;
        }

        .sidebar-header {
            padding: 30px 20px;
            background: rgba(255, 255, 255, 0.1);
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            margin-bottom: 20px;
            text-align: center;
        }

        .sidebar-title {
            font-size: 22px;
            font-weight: bold;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .nav-menu {
            list-style: none;
            padding: 0 15px;
        }

        .nav-item {
            margin-bottom: 8px;
        }

        .nav-link {
            display: flex;
            align-items: center;
            padding: 15px 20px;
            color: white;
            text-decoration: none;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            border-radius: 12px;
            border-left: 4px solid transparent;
        }

        .nav-link:hover, .nav-link.active {
            background: rgba(255, 255, 255, 0.1);
            border-left-color: #60a5fa;
            transform: translateX(5px);
        }

        .nav-icon {
            margin-right: 15px;
            font-size: 18px;
        }

        /* 右侧主内容区域 */
        .main-content {
            flex: 1;
            margin-left: 280px;
            padding: 30px;
            background: rgba(255, 255, 255, 0.95);
        }

        .content-header {
            background: white;
            padding: 25px 30px;
            border-radius: 15px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
        }

        .header-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .header-left h1 {
            font-size: 28px;
            color: #1e3a8a;
            margin-bottom: 8px;
        }

        .breadcrumb {
            color: #6b7280;
            font-size: 14px;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .user-avatar {
            width: 50px;
            height: 50px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            color: white;
        }

        .user-details {
            text-align: right;
        }

        .user-name {
            font-weight: bold;
            color: #1e3a8a;
            margin-bottom: 4px;
        }

        .user-role {
            color: #6b7280;
            font-size: 14px;
        }

        .btn-logout {
            background: #ef4444;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .btn-logout:hover {
            background: #dc2626;
        }

        /* 功能模块样式 */
        .function-module {
            background: white;
            border-radius: 15px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
            overflow: hidden;
        }

        .module-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px 30px;
            font-size: 18px;
            font-weight: bold;
        }

        .module-content {
            padding: 30px;
        }

        /* 数据表格样式 */
        .data-table {
            width: 100%;
            border-collapse: collapse;
            background: white;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .data-table th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 15px;
            text-align: left;
            font-weight: 600;
        }

        .data-table td {
            padding: 15px;
            border-bottom: 1px solid #e5e7eb;
        }

        .data-table tr:hover {
            background: #f8fafc;
        }

        .status-badge {
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
        }

        .status-pending {
            background: #fef3c7;
            color: #92400e;
        }

        .status-active {
            background: #dcfce7;
            color: #166534;
        }

        .status-completed {
            background: #dbeafe;
            color: #1e40af;
        }

        .status-cancelled {
            background: #fef2f2;
            color: #dc2626;
        }

        .action-buttons {
            display: flex;
            gap: 8px;
        }

        .btn-action {
            padding: 6px 12px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.3s ease;
        }

        .btn-action-view {
            background: #3b82f6;
            color: white;
        }

        .btn-action-view:hover {
            background: #2563eb;
        }

        .btn-action-edit {
            background: #f59e0b;
            color: white;
        }

        .btn-action-edit:hover {
            background: #d97706;
        }

        .btn-action-delete {
            background: #ef4444;
            color: white;
        }

        .btn-action-delete:hover {
            background: #dc2626;
        }

        .btn-action-match {
            background: #10b981;
            color: white;
        }

        .btn-action-match:hover {
            background: #059669;
        }

        .btn-action-approve {
            background: #8b5cf6;
            color: white;
        }

        .btn-action-approve:hover {
            background: #7c3aed;
        }

        /* 表单样式 */
        .form-container {
            background: white;
            border-radius: 15px;
            padding: 30px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
        }

        .form-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 25px;
        }

        .form-group {
            display: flex;
            flex-direction: column;
        }

        .form-label {
            font-weight: 600;
            color: #374151;
            margin-bottom: 8px;
        }

        .form-input {
            padding: 12px 15px;
            border: 2px solid #e5e7eb;
            border-radius: 8px;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        .form-input:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .form-textarea {
            padding: 12px 15px;
            border: 2px solid #e5e7eb;
            border-radius: 8px;
            font-size: 14px;
            transition: all 0.3s ease;
            resize: vertical;
            min-height: 100px;
        }

        .form-textarea:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .form-actions {
            display: flex;
            gap: 15px;
            justify-content: flex-end;
        }

        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        }

        .btn-secondary {
            background: #6b7280;
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .btn-secondary:hover {
            background: #4b5563;
        }

        .btn-danger {
            background: #dc2626;
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .btn-danger:hover {
            background: #b91c1c;
        }

        /* 搜索区域样式 */
        .search-container {
            background: white;
            border-radius: 15px;
            padding: 20px 30px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
        }

        .search-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            align-items: end;
        }

        .search-group {
            display: flex;
            flex-direction: column;
        }

        .search-label {
            font-weight: 600;
            color: #374151;
            margin-bottom: 8px;
        }

        .search-input {
            padding: 10px 15px;
            border: 2px solid #e5e7eb;
            border-radius: 8px;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        .search-input:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .search-actions {
            display: flex;
            gap: 10px;
        }

        .btn-search {
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .btn-search-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .btn-search-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        }

        .btn-search-secondary {
            background: #6b7280;
            color: white;
        }

        .btn-search-secondary:hover {
            background: #4b5563;
        }

        /* 表格响应式 */
        .table-container {
            overflow-x: auto;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .sidebar {
                width: 100%;
                position: relative;
                height: auto;
            }
            
            .main-content {
                margin-left: 0;
            }
            
            .header-top {
                flex-direction: column;
                gap: 20px;
                text-align: center;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 左侧侧边栏 -->
        <nav class="sidebar">
            <div class="sidebar-header">
                <div class="sidebar-title">志愿者管理系统</div>
            </div>
            
            <ul class="nav-menu">
                <li class="nav-item">
                    <a href="#" class="nav-link active" onclick="switchFunction('publish-demand')">
                        <span class="nav-icon">📢</span>
                        <span class="nav-text">发布需求</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link" onclick="switchFunction('system-match')">
                        <span class="nav-icon">🔗</span>
                        <span class="nav-text">系统匹配志愿者</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link" onclick="switchFunction('volunteer-registration')">
                        <span class="nav-icon">📝</span>
                        <span class="nav-text">志愿者报名</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="life-science-management.html" class="nav-link">
                        <span class="nav-icon">🏠</span>
                        <span class="nav-text">返回主页</span>
                    </a>
                </li>
            </ul>
        </nav>

        <!-- 右侧主内容区域 -->
        <main class="main-content">
            <div class="content-header">
                <div class="header-top">
                    <div class="header-left">
                        <h1>志愿者管理</h1>
                        <div class="breadcrumb">生命科学馆管理 > 志愿者管理</div>
                    </div>
                    <div class="user-info">
                        <div class="user-avatar">👤</div>
                        <div class="user-details">
                            <div class="user-name" id="current-user-name">志愿者管理员</div>
                            <div class="user-role" id="current-user-role">志愿者管理员</div>
                        </div>
                        <button class="btn-logout" onclick="logout()">退出登录</button>
                    </div>
                </div>
            </div>

            <!-- 发布需求功能 -->
            <div id="publish-demand-content" class="content-section">
                <div class="function-module">
                    <div class="module-header">发布志愿者需求</div>
                    <div class="module-content">
                        <div class="form-container">
                            <form id="demand-form">
                                <div class="form-grid">
                                    <div class="form-group">
                                        <label class="form-label">需求标题 *</label>
                                        <input type="text" class="form-input" name="title" required>
                                    </div>
                                    <div class="form-group">
                                        <label class="form-label">需求类型 *</label>
                                        <select class="form-input" name="type" required>
                                            <option value="">请选择需求类型</option>
                                            <option value="讲解服务">讲解服务</option>
                                            <option value="活动协助">活动协助</option>
                                            <option value="秩序维护">秩序维护</option>
                                            <option value="资料整理">资料整理</option>
                                            <option value="其他">其他</option>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label class="form-label">需求日期 *</label>
                                        <input type="date" class="form-input" name="date" required>
                                    </div>
                                    <div class="form-group">
                                        <label class="form-label">时间段 *</label>
                                        <select class="form-input" name="timeSlot" required>
                                            <option value="">请选择时间段</option>
                                            <option value="09:00-12:00">09:00-12:00</option>
                                            <option value="14:00-17:00">14:00-17:00</option>
                                            <option value="全天">全天</option>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label class="form-label">所需人数 *</label>
                                        <input type="number" class="form-input" name="requiredCount" min="1" required>
                                    </div>
                                    <div class="form-group">
                                        <label class="form-label">优先级 *</label>
                                        <select class="form-input" name="priority" required>
                                            <option value="">请选择优先级</option>
                                            <option value="高">高</option>
                                            <option value="中">中</option>
                                            <option value="低">低</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="form-label">需求描述 *</label>
                                    <textarea class="form-textarea" name="description" placeholder="请详细描述志愿者需求的具体内容、要求和工作职责..." required></textarea>
                                </div>
                                <div class="form-group">
                                    <label class="form-label">技能要求</label>
                                    <textarea class="form-textarea" name="skills" placeholder="请描述所需的技能要求，如语言能力、专业知识等..."></textarea>
                                </div>
                                <div class="form-actions">
                                    <button type="button" class="btn-secondary" onclick="resetDemandForm()">重置</button>
                                    <button type="submit" class="btn-primary">发布需求</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

                <div class="function-module">
                    <div class="module-header">已发布需求列表</div>
                    <div class="module-content">
                        <div class="search-container">
                            <div class="search-grid">
                                <div class="search-group">
                                    <label class="search-label">需求类型</label>
                                    <select class="search-input" id="demand-type-filter">
                                        <option value="">全部类型</option>
                                        <option value="讲解服务">讲解服务</option>
                                        <option value="活动协助">活动协助</option>
                                        <option value="秩序维护">秩序维护</option>
                                        <option value="资料整理">资料整理</option>
                                        <option value="其他">其他</option>
                                    </select>
                                </div>
                                <div class="search-group">
                                    <label class="search-label">状态</label>
                                    <select class="search-input" id="demand-status-filter">
                                        <option value="">全部状态</option>
                                        <option value="pending">待匹配</option>
                                        <option value="active">进行中</option>
                                        <option value="completed">已完成</option>
                                        <option value="cancelled">已取消</option>
                                    </select>
                                </div>
                                <div class="search-group">
                                    <label class="search-label">&nbsp;</label>
                                    <div class="search-actions">
                                        <button type="button" class="btn-search btn-search-primary" onclick="searchDemands()">搜索</button>
                                        <button type="button" class="btn-search btn-search-secondary" onclick="clearDemandSearch()">清除</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="table-container">
                            <table class="data-table">
                                <thead>
                                    <tr>
                                        <th>需求编号</th>
                                        <th>需求标题</th>
                                        <th>需求类型</th>
                                        <th>需求日期</th>
                                        <th>时间段</th>
                                        <th>所需人数</th>
                                        <th>已报名</th>
                                        <th>优先级</th>
                                        <th>状态</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="demand-table-body">
                                    <tr>
                                        <td>VD20240115001</td>
                                        <td>科普讲解志愿者</td>
                                        <td>讲解服务</td>
                                        <td>2024-01-20</td>
                                        <td>09:00-12:00</td>
                                        <td>3</td>
                                        <td>2</td>
                                        <td>高</td>
                                        <td><span class="status-badge status-pending">待匹配</span></td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewDemand('VD20240115001')">查看</button>
                                            <button class="btn-action btn-action-edit" onclick="editDemand('VD20240115001')">编辑</button>
                                            <button class="btn-action btn-action-match" onclick="matchVolunteers('VD20240115001')">匹配</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>VD20240115002</td>
                                        <td>活动秩序维护</td>
                                        <td>秩序维护</td>
                                        <td>2024-01-22</td>
                                        <td>14:00-17:00</td>
                                        <td>5</td>
                                        <td>5</td>
                                        <td>中</td>
                                        <td><span class="status-badge status-active">进行中</span></td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewDemand('VD20240115002')">查看</button>
                                            <button class="btn-action btn-action-edit" onclick="editDemand('VD20240115002')">编辑</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>VD20240115003</td>
                                        <td>资料整理协助</td>
                                        <td>资料整理</td>
                                        <td>2024-01-18</td>
                                        <td>全天</td>
                                        <td>2</td>
                                        <td>2</td>
                                        <td>低</td>
                                        <td><span class="status-badge status-completed">已完成</span></td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewDemand('VD20240115003')">查看</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 系统匹配志愿者功能 -->
            <div id="system-match-content" class="content-section" style="display: none;">
                <div class="function-module">
                    <div class="module-header">系统匹配志愿者</div>
                    <div class="module-content">
                        <div class="search-container">
                            <div class="search-grid">
                                <div class="search-group">
                                    <label class="search-label">需求编号</label>
                                    <input type="text" class="search-input" id="match-demand-id" placeholder="输入需求编号">
                                </div>
                                <div class="search-group">
                                    <label class="search-label">匹配状态</label>
                                    <select class="search-input" id="match-status-filter">
                                        <option value="">全部状态</option>
                                        <option value="pending">待匹配</option>
                                        <option value="matched">已匹配</option>
                                        <option value="confirmed">已确认</option>
                                    </select>
                                </div>
                                <div class="search-group">
                                    <label class="search-label">&nbsp;</label>
                                    <div class="search-actions">
                                        <button type="button" class="btn-search btn-search-primary" onclick="searchMatches()">搜索</button>
                                        <button type="button" class="btn-search btn-search-secondary" onclick="clearMatchSearch()">清除</button>
                                        <button type="button" class="btn-search btn-search-primary" onclick="autoMatch()">自动匹配</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="table-container">
                            <table class="data-table">
                                <thead>
                                    <tr>
                                        <th>匹配编号</th>
                                        <th>需求标题</th>
                                        <th>需求类型</th>
                                        <th>需求日期</th>
                                        <th>匹配志愿者</th>
                                        <th>匹配度</th>
                                        <th>志愿者评分</th>
                                        <th>匹配状态</th>
                                        <th>匹配时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="match-table-body">
                                    <tr>
                                        <td>VM20240115001</td>
                                        <td>科普讲解志愿者</td>
                                        <td>讲解服务</td>
                                        <td>2024-01-20</td>
                                        <td>张三、李四</td>
                                        <td>95%</td>
                                        <td>4.8</td>
                                        <td><span class="status-badge status-pending">待确认</span></td>
                                        <td>2024-01-15 10:30</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewMatch('VM20240115001')">查看</button>
                                            <button class="btn-action btn-action-approve" onclick="approveMatch('VM20240115001')">确认</button>
                                            <button class="btn-action btn-action-edit" onclick="adjustMatch('VM20240115001')">调整</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>VM20240115002</td>
                                        <td>活动秩序维护</td>
                                        <td>秩序维护</td>
                                        <td>2024-01-22</td>
                                        <td>王五、赵六、钱七</td>
                                        <td>88%</td>
                                        <td>4.6</td>
                                        <td><span class="status-badge status-active">已确认</span></td>
                                        <td>2024-01-15 14:20</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewMatch('VM20240115002')">查看</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>VM20240115003</td>
                                        <td>资料整理协助</td>
                                        <td>资料整理</td>
                                        <td>2024-01-18</td>
                                        <td>孙八、周九</td>
                                        <td>92%</td>
                                        <td>4.7</td>
                                        <td><span class="status-badge status-completed">已完成</span></td>
                                        <td>2024-01-15 09:15</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewMatch('VM20240115003')">查看</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 志愿者报名功能 -->
            <div id="volunteer-registration-content" class="content-section" style="display: none;">
                <div class="function-module">
                    <div class="module-header">志愿者报名管理</div>
                    <div class="module-content">
                        <div class="search-container">
                            <div class="search-grid">
                                <div class="search-group">
                                    <label class="search-label">志愿者姓名</label>
                                    <input type="text" class="search-input" id="volunteer-name-search" placeholder="输入志愿者姓名">
                                </div>
                                <div class="search-group">
                                    <label class="search-label">报名状态</label>
                                    <select class="search-input" id="registration-status-filter">
                                        <option value="">全部状态</option>
                                        <option value="pending">待审核</option>
                                        <option value="approved">已通过</option>
                                        <option value="rejected">已拒绝</option>
                                        <option value="completed">已完成</option>
                                    </select>
                                </div>
                                <div class="search-group">
                                    <label class="search-label">需求类型</label>
                                    <select class="search-input" id="registration-type-filter">
                                        <option value="">全部类型</option>
                                        <option value="讲解服务">讲解服务</option>
                                        <option value="活动协助">活动协助</option>
                                        <option value="秩序维护">秩序维护</option>
                                        <option value="资料整理">资料整理</option>
                                        <option value="其他">其他</option>
                                    </select>
                                </div>
                                <div class="search-group">
                                    <label class="search-label">&nbsp;</label>
                                    <div class="search-actions">
                                        <button type="button" class="btn-search btn-search-primary" onclick="searchRegistrations()">搜索</button>
                                        <button type="button" class="btn-search btn-search-secondary" onclick="clearRegistrationSearch()">清除</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="table-container">
                            <table class="data-table">
                                <thead>
                                    <tr>
                                        <th>报名编号</th>
                                        <th>志愿者姓名</th>
                                        <th>需求标题</th>
                                        <th>需求类型</th>
                                        <th>需求日期</th>
                                        <th>报名时间</th>
                                        <th>志愿者评分</th>
                                        <th>报名状态</th>
                                        <th>审核意见</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="registration-table-body">
                                    <tr>
                                        <td>VR20240115001</td>
                                        <td>张三</td>
                                        <td>科普讲解志愿者</td>
                                        <td>讲解服务</td>
                                        <td>2024-01-20</td>
                                        <td>2024-01-15 09:30</td>
                                        <td>4.8</td>
                                        <td><span class="status-badge status-pending">待审核</span></td>
                                        <td>-</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewRegistration('VR20240115001')">查看</button>
                                            <button class="btn-action btn-action-approve" onclick="approveRegistration('VR20240115001')">通过</button>
                                            <button class="btn-action btn-action-delete" onclick="rejectRegistration('VR20240115001')">拒绝</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>VR20240115002</td>
                                        <td>李四</td>
                                        <td>科普讲解志愿者</td>
                                        <td>讲解服务</td>
                                        <td>2024-01-20</td>
                                        <td>2024-01-15 10:15</td>
                                        <td>4.6</td>
                                        <td><span class="status-badge status-active">已通过</span></td>
                                        <td>经验丰富，适合</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewRegistration('VR20240115002')">查看</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>VR20240115003</td>
                                        <td>王五</td>
                                        <td>活动秩序维护</td>
                                        <td>秩序维护</td>
                                        <td>2024-01-22</td>
                                        <td>2024-01-15 11:20</td>
                                        <td>4.5</td>
                                        <td><span class="status-badge status-active">已通过</span></td>
                                        <td>责任心强</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewRegistration('VR20240115003')">查看</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>VR20240115004</td>
                                        <td>赵六</td>
                                        <td>资料整理协助</td>
                                        <td>资料整理</td>
                                        <td>2024-01-18</td>
                                        <td>2024-01-15 14:45</td>
                                        <td>4.2</td>
                                        <td><span class="status-badge status-cancelled">已拒绝</span></td>
                                        <td>时间冲突</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewRegistration('VR20240115004')">查看</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <script>
        // 页面加载时设置用户信息
        document.addEventListener('DOMContentLoaded', function() {
            const currentUser = localStorage.getItem('volunteerCurrentUser');
            if (currentUser) {
                const user = JSON.parse(currentUser);
                document.getElementById('current-user-name').textContent = user.name || '志愿者管理员';
                document.getElementById('current-user-role').textContent = user.role || '志愿者管理员';
            }
        });

        // 功能切换
        function switchFunction(functionName) {
            // 移除所有活动状态
            document.querySelectorAll('.nav-link').forEach(link => {
                link.classList.remove('active');
            });
            
            // 添加活动状态到当前点击的链接
            event.target.closest('.nav-link').classList.add('active');
            
            // 隐藏所有内容
            const allContent = document.querySelectorAll('.content-section');
            allContent.forEach(content => {
                content.style.display = 'none';
            });

            // 显示对应内容
            const targetContent = document.getElementById(functionName + '-content');
            if (targetContent) {
                targetContent.style.display = 'block';
            }
        }

        // 发布需求相关函数
        document.getElementById('demand-form').addEventListener('submit', function(e) {
            e.preventDefault();
            const formData = new FormData(this);
            
            // 获取表单数据
            const demandData = {
                id: 'VD' + Date.now(),
                title: formData.get('title'),
                type: formData.get('type'),
                date: formData.get('date'),
                timeSlot: formData.get('timeSlot'),
                requiredCount: formData.get('requiredCount'),
                priority: formData.get('priority'),
                description: formData.get('description'),
                skills: formData.get('skills')
            };

            // 这里可以添加数据验证和提交逻辑
            console.log('发布需求数据:', demandData);
            alert('需求发布成功！');
            
            // 重置表单
            this.reset();
        });

        function resetDemandForm() {
            document.getElementById('demand-form').reset();
        }

        function searchDemands() {
            const type = document.getElementById('demand-type-filter').value;
            const status = document.getElementById('demand-status-filter').value;
            alert(`搜索需求: 类型: ${type}, 状态: ${status}`);
        }

        function clearDemandSearch() {
            document.getElementById('demand-type-filter').value = '';
            document.getElementById('demand-status-filter').value = '';
        }

        function viewDemand(id) {
            alert(`查看需求详情 ID: ${id}`);
        }

        function editDemand(id) {
            alert(`编辑需求 ID: ${id}`);
        }

        function matchVolunteers(id) {
            alert(`匹配志愿者 ID: ${id}`);
        }

        // 系统匹配志愿者相关函数
        function searchMatches() {
            const demandId = document.getElementById('match-demand-id').value;
            const status = document.getElementById('match-status-filter').value;
            alert(`搜索匹配: 需求ID: ${demandId}, 状态: ${status}`);
        }

        function clearMatchSearch() {
            document.getElementById('match-demand-id').value = '';
            document.getElementById('match-status-filter').value = '';
        }

        function autoMatch() {
            alert('开始自动匹配志愿者...');
        }

        function viewMatch(id) {
            alert(`查看匹配详情 ID: ${id}`);
        }

        function approveMatch(id) {
            if (confirm('确定要确认这个匹配吗？')) {
                alert(`确认匹配 ID: ${id}`);
            }
        }

        function adjustMatch(id) {
            alert(`调整匹配 ID: ${id}`);
        }

        // 志愿者报名相关函数
        function searchRegistrations() {
            const name = document.getElementById('volunteer-name-search').value;
            const status = document.getElementById('registration-status-filter').value;
            const type = document.getElementById('registration-type-filter').value;
            alert(`搜索报名: 姓名: ${name}, 状态: ${status}, 类型: ${type}`);
        }

        function clearRegistrationSearch() {
            document.getElementById('volunteer-name-search').value = '';
            document.getElementById('registration-status-filter').value = '';
            document.getElementById('registration-type-filter').value = '';
        }

        function viewRegistration(id) {
            alert(`查看报名详情 ID: ${id}`);
        }

        function approveRegistration(id) {
            if (confirm('确定要通过这个报名申请吗？')) {
                alert(`通过报名 ID: ${id}`);
            }
        }

        function rejectRegistration(id) {
            if (confirm('确定要拒绝这个报名申请吗？')) {
                alert(`拒绝报名 ID: ${id}`);
            }
        }

        // 退出登录
        function logout() {
            localStorage.removeItem('volunteerIsLoggedIn');
            localStorage.removeItem('volunteerCurrentUser');
            window.location.href = 'life-science-management.html';
        }
    </script>
</body>
</html>
